def read_data_by_labels(sample_file, label_file):
    data = [[] for i in range(10)]
    sample_lines = open(sample_file, 'r').readlines()
    label_lines = open(label_file, 'r').readlines()
    for sample_line, label_line in zip(sample_lines, label_lines):
        label = int(label_line.strip())
        sample = [float(n) for n in sample_line.strip().split(',')]
        sample.append(float(1))
        data[label].append(sample)
    return data
